//
//  GNRAlertConfiguration.m
//  Pods
//
//  Created by LvYuan on 2017/9/12.
//
//

#import "GNRAlertConfiguration.h"

@implementation GNRAlertConfiguration

+ (CGFloat)kDownLimitMoney{
    return 1.0;
}

+ (CGFloat)kDefaultUpLimitMoney{
    return 2000.f;
}

+ (CGFloat)kMaxUpLimitMoney{
    return 100000000.0;
}

+ (CGFloat)kDefaultCountDownMaxTime{
    return 30;
}

+ (CGFloat)kAlertInitScale{
    return 0.8;
}

+ (CGFloat)kDefaultAlertWidth{
    return 300.f;
}

- (void)dealloc{
    GNRAlertLog(@"GNRAlertConfiguration dealloc");
}

- (instancetype)init{
    if (self = [super init]) {
        self.style = GNRAlertStyleDefault;
    }
    return self;
}

- (void)configDefaultStyle{
    _kGNRAlertAnimationDuration = 0.2;
    _kGNRAlertKeyBHeight = 216.f;
    _kUHeight = 40.f;
    _kUIconSize = 31.f;
    _kAlertWidth = 261.f;
    _kAlertHeight =200;
    _kBtnHeight =45.f;
    _kHeaderHeight =40.f;
    _kBotmPadding = 13;
    _kLeadPadding = 14;
    _kPadding =13;
    _kTopPadding = 13;
    _kTitMsgPadding = 8;
    _kTitFontSize =15;
    _kMsgFontSize =14;
    _kMaxHeight = 200.f;
    _kSpace = 0.8;
    _kLineSpace = 2;
    _kMaxWidth = _kAlertWidth - 2 * _kLeadPadding;
}

- (void)configBigStyle{
    _kUHeight = 0.f;
    _kAlertWidth = GNRAlertConfiguration.kDefaultAlertWidth;
    _kAlertHeight =200.f;
    _kHeaderHeight = 100.f;
    _kTitFontSize =20;
    _kMsgFontSize =16;
    _kSpace = 0.8;
    _kMaxWidth = _kAlertWidth - 2 * _kLeadPadding;
}

- (void)configNoHeader{
    _kAlertWidth = GNRAlertConfiguration.kDefaultAlertWidth;
    _kHeaderHeight = 0.f;
    _kPadding = 26.f;
    _kTopPadding = 30.f;
    _kBotmPadding = 26.f;
    _kTitMsgPadding = 20.f;
    _kTitFontSize = 18;
    _kMsgFontSize = 13;
    _kMaxWidth = _kAlertWidth - 2.0 * _kLeadPadding;
    _kLineSpace = 8;
}

- (void)configShare{
    _kAlertWidth = GNRAlertConfiguration.kDefaultAlertWidth;
    _kHeaderHeight = 285;
    _kTopPadding = -30;
    _kBtnHeight =50.f;
    _kTitFontSize = 15;
    _kMsgFontSize = 19;
    _kTitMsgPadding = 12;
    _kBotmPadding = 30.f;
    _kMaxWidth = _kAlertWidth - 2.0 * _kLeadPadding;
}

- (void)configMerchant{
    _kUIconSize = 54.f;
    _kAlertWidth = GNRAlertConfiguration.kDefaultAlertWidth;
    _kHeaderHeight =100.f;
    _kBotmPadding = 22;
    _kLeadPadding = 21;
    _kPadding =13;
    _kTopPadding = 20;
    _kTitMsgPadding = 8;
    _kTitFontSize =16;
    _kMsgFontSize =12;
    _kSpace = 0.8;
    _kLineSpace = 2;
    _kMaxWidth = _kAlertWidth - 2 * _kLeadPadding;
}

- (CGFloat)gnr_screenMinWidth{
    CGSize size = GNR_SCREENBOUNDS.size;
    return size.width<=size.height?size.width:size.height;
}

- (instancetype)initWithStyle:(GNRAlertStyle)style{
    if (self = [super init]) {
        self.style = style;
    }
    return self;
}

- (void)setStyle:(GNRAlertStyle)style{
    [self configDefaultStyle];
    switch (style) {
            case GNRAlertStyleBig:
        {
            [self configBigStyle];
        }
            break;
            case GNRAlertStyleNoHeader:
        {
            [self configNoHeader];
        }
            break;
            case GNRAlertStyleShare:
        {
            [self configShare];
        }
            break;
            case GNRAlertStyleMerchant:
        {
            [self configMerchant];
        }
            break;
        default:
            break;
    }
}

+ (GNRAlertConfiguration *)configurationWithStyle:(GNRAlertStyle)style{
    GNRAlertConfiguration * configuration = [[GNRAlertConfiguration alloc]initWithStyle:style];
    return configuration;
}

@end
